package com.android.awacs.wifi;

import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;

class WiFiPingIP extends Thread {

	private InetAddress ip;
	private ArrayList<String> list;

	public WiFiPingIP(String adresse, ArrayList<String> list) {
		try {
			ip = InetAddress.getByName(adresse);
			this.list = list;
		} catch (UnknownHostException ex) {
			Logger.getLogger(WiFiScanIP.class.getName()).log(Level.SEVERE, null, ex);
		}
	}

	public void run() {
		try {
			if (ip.isReachable(2000)) {
				synchronized (this.list) {
					this.list.add(ip.toString().substring(1));
				}
			}
		} catch (IOException ex) {
			Logger.getLogger(WiFiScanIP.class.getName()).log(Level.SEVERE, null, ex);
		}
	}
}